Skip to content

Instantly share code, notes, and snippets.

@hurricane-voronin
hurricane-voronin / README.md
Last active May 21, 2024 01:19
Naming Classes Without a 'Manager'
@bsdayo
bsdayo / make-shortcut.ps1
Last active May 21, 2024 01:17
Super "Windows shortcut" maker with embedded icon
param(
[Parameter(Mandatory)] [string] $Command,
[Parameter(Mandatory)] [string] $IconFile,
[string] $Output,
[switch] $Keep
)
(Get-Content -Encoding UTF8 template.c) -replace "COMMAND_PLACEHOLDER", ($Command -replace '\\', '\\') | Out-File -Encoding UTF8 temp.c
"icon ICON `"$($IconFile -replace '\\', '\\')`"" | Out-File -Encoding UTF8 temp.rc
@enesien
enesien / shadcn-multi-tag-input.md
Last active May 21, 2024 01:16
shadcn multiple tag input

shadcn/ui multi tag input component

A react tag input field component using shadcn, like one you see when adding keywords to a video on YouTube. Usable with Form or standalone.

Preview

image

Standalone Usage

@squarism
squarism / iterm2.md
Last active May 21, 2024 01:14
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@morvanabonin
morvanabonin / comandos-docker
Last active May 21, 2024 01:13
Comandos do Docker
Segue a lista de comandos docker e sua utilidade:
docker attach – Acessar dentro do container e trabalhar a partir dele.
docker build – A partir de instruções de um arquivo Dockerfile eu possa criar uma imagem.
docker commit – Cria uma imagem a partir de um container.
docker cp – Copia arquivos ou diretórios do container para o host.
docker create – Cria um novo container.
docker diff – Exibe as alterações feitas no filesystem do container.
docker events – Exibe os eventos do container em tempo real.
docker exec – Executa uma instrução dentro do container que está rodando sem precisar atachar nele.
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active May 21, 2024 01:11
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

Dockerized 实践 https://github.com/y0ngb1n/dockerized

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

@vadimkantorov
vadimkantorov / packbits.py
Last active May 21, 2024 01:01
Pack bool and other integer tensors into smaller bitwidth in PyTorch (e.g. save 8x memory on BoolTensors), inspired by np.packbits / np.unpackbits
# PyTorch bit packing inspired by np.packbits / np.unpackbits. Feature request: https://github.com/pytorch/pytorch/issues/32867
import math
import torch
def tensor_dim_slice(tensor, dim, dim_slice):
return tensor[(dim if dim >= 0 else dim + tensor.dim()) * (slice(None), ) + (dim_slice, )]
#@torch.jit.script
def packshape(shape, dim : int = -1, mask : int = 0b00000001, dtype = torch.uint8, pack = True):
:: Save this as SteamTrackingFix.bat and place it in your Godot folder.
:: The name doesn't really matter, but you may need to enable viewing file extensions in Windows to save it as a batch file.
:: Run this again if Godot updates and steam tracking stops working.
@echo off
echo -----
echo Don't forget to add '/K godot.exe' to your Steam Godot Launch Options!
echo -----
:: BatchGotAdmin
:-------------------------------------
#!/bin/bash
# Update and upgrade system packages
sudo apt update
sudo apt upgrade -y
# Install required packages
sudo apt install -y wget git build-essential cmake libprotobuf-dev protobuf-compiler libsqlite3-dev zlib1g-dev osmium-tool nodejs npm nginx
# Download OSM data for Berlin
@nestoralvaro
nestoralvaro / konamiCode.js
Created January 11, 2012 22:30
Snippet to detect Konami Code (and then do something)
/******************************************************************************
* This script detects the Konami code
* (Full Konami Code obtained from: http://en.wikipedia.org/wiki/Konami_Code)
* If the Konami code is detected the function called "startUpKonami" is invoked.
* You can do whatever you want on "startUpKonami". Right now this method just:
* - Detachs the Konami code detection (so no further detections can happen).
* - Invokes an external function.
*
* Note: In case the user presses keys like "shift", "caps lock", "Ctrl"...
* the code will have to be reentered from scratch